<template>
    <div class="iccidimport" :style="{minHeight:h+'px'}">
        <upload-excel-component @on-selected-file="exportData" buttonName="导入号码"></upload-excel-component>
    </div>
</template>

<script>
    import UploadExcelComponent from "@/components/UploadExcel/index.vue";
    import axios from "axios";
    export default{
    	components: {
    		UploadExcelComponent
    	},
    	name: 'iccidimport',
    	data(){
    		return{
    			h:"",
                list:[],
                hreflist:[]
    		}
    	},
    	created() {
    		var h = document.documentElement.clientHeight;
    		this.h = h;
            document.getElementsByTagName("title")[0].innerText = '金麦物联';
    	},
        methods:{
            //导入敏感地区
            exportData:function(data) {
                var list = []
                var hreflist = []
            	for(var i = 0 ;i < data.results.length; i++){
                    list.push(
                        {"iccid":data.results[i]['号码'],"url":data.results[i]['地址']}
                    )
            	}
                this.list = list
                this.hreflist = hreflist
                axios.post('/api/system/iccids/import',{iccids:this.list})
                	.then(response => {
                        console.log(response.data.msg.code)
                		if(response.data.msg.code == 0){
                            this.$message({
                              message: '导入成功！',
                              type: 'success'
                            });
                        }else{
                            this.$message.error(response.data.msg.info);
                        }
                	})
            }
        }
    }
</script>

<style lang="scss" scoped>
	.iccidimport{
		margin: 0; padding: 0; background: #EFEFEF; display: flex; justify-content: center; align-items: center;
		.el-button--primary{ background: #409EFF !important; border: 1px #409EFF solid !important;}
	}
</style>
